<template>
  <el-main>
    <div class="margin-bottom-20">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/device' }"
          >设备管理
        </el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '/device/bind' }"
          >库存设备
        </el-breadcrumb-item>
        <el-breadcrumb-item>设备上报历史</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-card class="box-card" shadow="never">
      <el-table :data="table_data" stripe style="width: 100%">
        <el-table-column label="上报时间" prop="ctime" width="160" />
        <el-table-column label="满溢" prop="fullState" />
        <el-table-column label="高度" prop="height" />
        <el-table-column label="火灾" prop="fireState" />
        <el-table-column label="温度" prop="temperature" />
        <el-table-column label="倾倒" prop="fallState" />
        <el-table-column label="倾倒角度" prop="angle" />
        <el-table-column label="设备状态" prop="deviceStatus" />
        <el-table-column label="检测时间" prop="unixTime" />
        <el-table-column label="帧计数器" prop="frameCount" />
        <el-table-column label="所在小区" prop="cell" />
        <el-table-column label="电压" prop="voltage" />
        <el-table-column label="SNR" prop="snr" />
        <el-table-column label="电池状态" prop="batteryQuantityStatus" />
        <el-table-column label="RSRP" prop="rsrp" />
        <el-table-column label="信号等级" prop="sign" />
        <el-table-column label="经度" prop="lng" />
        <el-table-column label="纬度" prop="lat" />
      </el-table>
      <div class="margin-top-10 clearfix">
        <el-pagination
          :current-page.sync="current_page"
          :page-size.sync="page_size"
          :page-sizes="[5, 10, 20]"
          :total="total_size"
          @current-change="load_table_data"
          @size-change="load_table_data"
          background
          class="pull-right"
          layout="total, sizes,  prev, pager, next"
        />
      </div>
    </el-card>
  </el-main>
</template>

<script>
import { mapActions, mapState } from "vuex";

export default {
  data() {
    return {
      id: null
    };
  },
  computed: {
    ...mapState("device_report", ["total_size", "table_data"]),
    page_size: {
      get() {
        return this.$store.state.device_report.page_size;
      },
      set(value) {
        this.set_page_size(value);
      }
    },
    current_page: {
      get() {
        return this.$store.state.device_report.current_page;
      },
      set(value) {
        this.set_current_page(value);
      }
    }
  },
  mounted() {
    this.id = this.$route.params.id;
    this.set_search_param({ deviceBaseId: this.id });
    this.load_table_data();
  },
  methods: {
    ...mapActions("device_report", [
      "load_table_data",
      "set_page_size",
      "set_current_page",
      "set_search_param"
    ])
  }
};
</script>
